package com.lau.xstream;

import com.lau.xstream.bean.Author;
import com.thoughtworks.xstream.converters.SingleValueConverter;

/**
 * Created by liutf on 2016/6/13.
 */
public class AuthorConverter implements  SingleValueConverter {
    @Override
    public String toString(Object o) {
        return ((Author)o).getName();
    }

    @Override
    public Object fromString(String name) {
        return new Author(name);
    }

    @Override
    public boolean canConvert(Class type) {
        return type.equals(Author.class);
    }
}
